﻿using VideoSeller.Business.Models;
using VideoSeller.Core.Interfaces;

namespace VideoSeller.Business.Providers
{
	public class DatabaseSettingsProvider : IDatabaseSettingsProvider
	{
		private readonly SettingsModel _settingsModel;

		public DatabaseSettingsProvider(SettingsModel settingsModel)
		{
			_settingsModel = settingsModel;
		}

		public int RatingStep
		{
			get { return int.Parse(_settingsModel.GetSetting("RatingStep").Value); }
		}

		public int AnnouncementWaitingTime
		{
			get { return int.Parse(_settingsModel.GetSetting("AnnouncementWaitingTime").Value); }
		}
        public int MaxInactiveOnlineInMinutes
        {
            get {
                int ret = 0;
                if (int.TryParse(_settingsModel.GetSetting("MaxInactiveOnlineInMinutes").Value, out ret))
                    return ret;
                else
                    return 60 * 6;
            }
        }
		public int RecommendedDays
		{
			get { return int.Parse(_settingsModel.GetSetting("RecommendedDays").Value); }
		}

		public int MeetingPriceForMember
		{
			get { return int.Parse(_settingsModel.GetSetting("MeetingPriceForMember").Value); }
		}
        public int WithdrawalMin
        {
            get { return int.Parse(_settingsModel.GetSetting("WithdrawalMin").Value); }
        }

		public string MainWebPath
		{
			get { return _settingsModel.GetSetting("MainWebPath").Value; }
		}

		public string PayPalMerchantId
		{
			get { return _settingsModel.GetSetting("PayPalMerchantId").Value; }
		}

		public string PayPalEnvironment
		{
			get { return _settingsModel.GetSetting("PayPalEnvironment").Value; }
		}

		public string PayPalCallbackUrl
		{
			get { return _settingsModel.GetSetting("PayPalCallbackUrl").Value; }
		}

		public int UsdToVsl
		{
            get { return 1; }// vladimir int.Parse(_settingsModel.GetSetting("UsdToVsl").Value); }
		}

		public string UsdToVslDescription
		{
            get { return ""; } //vladimir  _settingsModel.GetSetting("UsdToVsl").Description; }
		}

		public bool ShowResourceNumber
		{
			get
			{
				bool value;

				if (bool.TryParse(_settingsModel.GetSetting("ShowResourceNumber").Value, out value))
				{
					return value;
				}

				return value;
			}
		}

		public int WithdrawalTimer
		{
			get { return int.Parse(_settingsModel.GetSetting("WithdrawalTimer").Value); }
		}

		public bool SkipClaimsCheck
		{
			get
			{
				bool value;

				if (bool.TryParse(_settingsModel.GetSetting("SkipClaimsCheck").Value, out value))
				{
					return value;
				}

				return value;
			}
		}

		public short ConferenceMembersCount
		{
			get { return short.Parse(_settingsModel.GetSetting("ConferenceMembersCount").Value); }
		}
	}
}